<?php
namespace App\HttpController\Admin;

use App\Common\Controller\Rest;
use App\Model\Administrator;
use App\Validate\MemberStatusValidate;
use think\Cache;
use EasySwoole\Config;

class MemberStatus extends Rest
{
    public $modelName = 'Member';   // model 类名称

    /**
     * 登录
     */
    public function POSTIndex()
    {
        $validate = new MemberStatusValidate();
        $this->abort($validate->scene('Update')->check($this->param), ['msg' => $validate->getError()]);
        $username = $this->param['username'];
        $password = $this->param['password'];
        $verifyCode = !empty($this->param['verifyCode']) ? $this->param['verifyCode'] : '';
        $isRemember = !empty($this->param['isRemember']) ? $this->param['isRemember'] : '';
        $model = new Administrator();
        $resData = $model->login($username, $password, $verifyCode, $isRemember);
        // 检查是否抛出异常
        $this->abort($resData, ['msg' => $model->getError()]);
        // 处理结果 
        $this->jsonData($resData, ['msg' => '数据异常']);
    }
}
